<!--应急资源-->
<template>
	<Layout>
		<div v-if="statisticPage">
			<Form ref="form1" :model="dataToQuery" :label-width="120">
				<Row class="query-form">
          <Col span="8">
            <FormItem label="单位名称：" prop="order">
              <company-select v-model="dataToQuery.companyName" class="query-form-el"></company-select>
            </FormItem>
          </Col>
          <Col span="8">
            <FormItem label="二级集团：">
              <two-level-org org-code class="query-form-el" v-model="dataToQuery.twoLevelOrgId"></two-level-org>
            </FormItem>
          </Col>
          <Col span="8">
            <!-- <Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button> -->
            <Button @click="reset" class="ivu-btn-reset">重置</Button>
            <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
          </Col>
        </Row>
				<Row class="query-form">
					<Col span="24">
						<Button size="large" class="ivu-btn-add" icon="md-add" @click="addInfo">新增</Button>
						<Button icon="md-cloud-upload" class="ivu-btn-add" @click="openUpload">导入应急资源</Button>
						<Button icon="md-download" class="ivu-btn-add" @click="downloadModel">下载模板</Button>
					</Col>
				</Row>
			</Form>
		</div>
		<div v-else>
			<Form ref="form1" :model="dataToQuery" :label-width="120">
				<Row class="query-form">
					<Col span="8">
					<FormItem label="单位名称：" prop="order">
						<cascader-dom class="query-form-el" ref='queryOrgCascader' @setOrgInfo='setQueryCompanyName'
							@setOrgname='setQueryOrgName' :orgTree="true"
							:setCurrentName="{label:dataToQuery.companyName,value:dataToQuery.companyId}"></cascader-dom>
					</FormItem>
					</Col>
					<Col span="8">
					<FormItem label='类型/代码：' prop='typeArr'>
						<Cascader v-model='dataToQuery.typeArr' :data="dictMap.typeArr" trigger="hover" change-on-select></Cascader>

						<!-- <Select v-model='dataToQuery.type' placeholder="请选择类型/代码" label-in-value
							class='query-form-el'>
							<Option v-for="item in dictMap.typeArr" :value="item.codingCodeId"
								:key="item.codingCodeId">{{item.codingName }}</Option>
						</Select> -->
					</FormItem>
					</Col>
					<Col span="8" v-if="!switchFlag" >
					<Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button>
					<Button @click="reset" class="ivu-btn-reset">重置</Button>
					<Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
					</Col>
					<Col span="8" v-else>
						<!-- <FormItem label='装备名称：' prop='equipmentName'>
							<Input class='query-form-el' placeholder="请填写装备名称" type='text'
							v-model='dataToQuery.equipmentName'></Input>
						</FormItem> -->
						<FormItem label='规格型号：' prop='specification'>
						<Input class='query-form-el' placeholder="请填写规格型号" type='text'
						v-model='dataToQuery.specification'></Input>
						</FormItem>
					</Col>
				</Row>
				<Row v-show="switchFlag" class="query-form">
					<!-- <Col span="8">
					<FormItem label='规格型号：' prop='specification'>
						<Input class='query-form-el' placeholder="请填写规格型号" type='text'
						v-model='dataToQuery.specification'></Input>
					</FormItem>
					</Col> -->
					<Col span="8" offset='16'>
					<Button @click="switchQuery(false)" class="ivu-btn-switch" type="text">收起∧</Button>
					<Button @click="reset" class="ivu-btn-reset">重置</Button>
					<Button class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
					</Col>
				</Row>
				<Row class="query-form">
					<Col span="24">
						<Button size="large" class="ivu-btn-add" icon="md-add" @click="addInfo">新增</Button>
						<Button type="primary" class="ivu-btn-add" icon="md-cloud-download" @click="exportFormSubmit">导出</Button>
						<Button size="large" class="ivu-btn-add" icon="md-arrow-back"  @click="goback">返回</Button>
					</Col>
				</Row>
			</Form>
		</div>
		<Table ref='table' :height="tableHeight" no-data-text="没有查询到相关数据!" @on-selection-change='getSelectRows' @on-sort-change="querySort"
			:loading='pageStatus.loading' border :columns="statisticPage?columns2:columns1" :data="dataTable">
		</Table>
		<Row style="margin-right:10px;">
			<Col span="24">
			<Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize" @on-change="pageChange"
				@on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray" show-total show-sizer
				show-elevator />
			</Col>
		</Row>
		<Modal :title="this.getModalTitle('应急资源')" :transfer=false :mask-closable="false" v-model="dialogShow"
			v-if="dataToView && dialogShow" :width=800 :styles="{maxHeight:'700px'}" class-name='limit-height-dialog'>
			<Row>
				<Col span="24">
				<Form ref="dialogForm" :class="mode === 'view'?'modal-view-detail':''" :show-message="false"
					:model="dataToView" :rules="mode === 'view'?{}:ruleCustom" :label-width="mode === 'view'?120:null"
					:label-position="mode === 'view'?'right':'top'">
					<Row type="flex" justify="space-around" class="code-row-bg">
						<Col span="11">
						<FormItem label='单位名称：' prop='companyId'>
							<div v-if="mode === 'view'">{{ dataToView.companyName }}</div>
							<cascaderDom class="query-form-el" ref="companyQuery" :orgTree="true" v-else
								:currentOrgId="dataToView.companyId" style="width: 100%"
								:setCurrentName="{label:dataToView.companyName, value:dataToView.companyId}"
								@setOrgInfo='(data)=>{ if (data && data instanceof Array && data.length > 0 ) {this.$set(this.dataToView, "companyId", data[data.length - 1])}}'
								@setOrgname='(data)=>{ if(data){this.$set(this.dataToView, "companyName", data)}}'>
							</cascaderDom>
						</FormItem>
						</Col>
						<Col span="11">
						<FormItem label='地理位置：' prop='address'>
							<div v-if="mode === 'view'">{{ dataToView.address }}</div>
							<Input v-else class='query-form-el' placeholder="A省B市C县D街道1号" type='text' maxlength="100"
								show-word-limit v-model='dataToView.address'></Input>
						</FormItem>
						</Col>
					</Row>
					<Row type="flex" justify="space-around" class="code-row-bg">
						<!-- <Col span="11">
						<FormItem label='装备名称：' prop='equipmentName'>
							<div v-if="mode === 'view'">{{ dataToView.equipmentName }}</div>
							<Input v-else class='query-form-el' placeholder="请填写装备名称" type='text' maxlength="50"
								show-word-limit v-model='dataToView.equipmentName'></Input>
						</FormItem>
						</Col> -->
						<Col span="11">
						<FormItem label='类型/代码：' prop='type'>
							<div v-if="mode === 'view'">{{ dataToView.typeName }}</div>
							<!-- <Input v-else class='query-form-el' placeholder="请填写类型" type='text' maxlength="50" show-word-limit v-model='dataToView.type'></Input> -->
							<Cascader v-else v-model='dataToView.type' :data="dictMap.typeArr" trigger="hover" ></Cascader>
							<!-- <Select v-else v-model='dataToView.type' placeholder="请选择类型/代码" label-in-value class='query-form-el'>
								<Option v-for="item in dictMap.typeArr" :value="item.codingCodeId"
									:key="item.codingCodeId">{{item.codingName }}</Option>
							</Select> -->
						</FormItem>
						</Col>
						<Col span="11">
						<FormItem label='规格型号：' prop='specification'>
							<div v-if="mode === 'view'">{{ dataToView.specification }}</div>
							<Input v-else class='query-form-el' placeholder="请填写规格型号" type='text' maxlength="50"
								show-word-limit v-model='dataToView.specification'></Input>
						</FormItem>
						</Col>
					</Row>
					<Row type="flex" justify="space-around" class="code-row-bg">
						<Col span="11">
						<FormItem label='数量：' prop='number'>
							<div v-if="mode === 'view'">{{ dataToView.number }}</div>
							<InputNumber v-else class='query-form-el' placeholder="请填写数量" :min="0" type='text'
								v-model='dataToView.number'></InputNumber>
						</FormItem>
						</Col>
						<Col span="11">
						<FormItem label='来源：' prop='source'>
							<div v-if="mode === 'view'">{{ dataToView.source }}</div>
							<Input v-else class='query-form-el' placeholder="请填写来源" type='text' maxlength="50"
								show-word-limit v-model='dataToView.source'></Input>
						</FormItem>
						</Col>
					</Row>
					<Row type="flex" justify="space-around" class="code-row-bg">
						<Col span="11">
						<FormItem label='完好情况或有效期：' prop='completionDesc'>
							<div v-if="mode === 'view'">{{ dataToView.completionDesc }}</div>
							<Input v-else class='query-form-el' placeholder="请填写完成情况或有效期" type='text' maxlength="100"
								show-word-limit v-model='dataToView.completionDesc'></Input>
						</FormItem>
						</Col>
						<Col span="11">
						<FormItem label='存放场所：' prop='storageLocation'>
							<div v-if="mode === 'view'">{{ dataToView.storageLocation }}</div>
							<Input v-else class='query-form-el' placeholder="请填写存放场所" type='text' maxlength="100"
								show-word-limit v-model='dataToView.storageLocation'></Input>
						</FormItem>
						</Col>
					</Row>
					<Row type="flex" justify="space-around" class="code-row-bg">
						<Col span="23">
						<FormItem label='主要功能：' prop='mainFunction'>
							<div v-if="mode === 'view'">{{ dataToView.mainFunction }}</div>
							<Input v-else class='query-form-el' placeholder="请填写主要功能" type='textarea'
								:autosize="{minRows:2,maxRows:5}" maxlength="200" show-word-limit
								v-model='dataToView.mainFunction'></Input>
						</FormItem>
						</Col>
					</Row>
					<Row type="flex" justify="space-around" class="code-row-bg">
						<Col span="11">
						<FormItem label='负责人：' prop='chargeUserId'>
							<div v-if="mode === 'view'">{{ dataToView.chargeUserId }}</div>
							<Input v-else class='query-form-el' placeholder="请填写负责人" type='text' maxlength="5"
								show-word-limit v-model='dataToView.chargeUserId'></Input>
						</FormItem>
						</Col>
						<Col span="11">
						<FormItem label='负责人电话：' prop='chargeUserPhone'>
							<div v-if="mode === 'view'">{{ dataToView.chargeUserPhone }}</div>
							<Input v-else class='query-form-el' placeholder="请填写负责人电话" type='text'
							 v-model='dataToView.chargeUserPhone'></Input>
						</FormItem>
						</Col>
					</Row>

					<Row type="flex" justify="space-around" class="code-row-bg">
						<Col span="11">
						<FormItem label='填报人：' prop='createUserName'>
							<div v-if="mode === 'view'">{{ dataToView.createUserName }}</div>
							<Input v-else class='query-form-el' placeholder="请填写填报人" readonly type='text'
								v-model='dataToView.createUserName'></Input>
						</FormItem>
						</Col>
						<Col span="11">
						<FormItem label='填报时间：' prop='createDate'>
							<div v-if="mode === 'view'">{{ renderViewDate(dataToView.createDate) }}</div>
							<DatePicker v-else class="query-form-el" placeholder="请选择填报时间" readonly
								v-model='dataToView.createDate'></DatePicker>
						</FormItem>
						</Col>
					</Row>
				</Form>
				</Col>
			</Row>
			<div slot="footer">
				<Button v-if="mode != 'view'" type="primary" class='ivu-btn-save'
					@click="submit('dialogForm')">确定</Button>
				<Button v-if="mode != 'view'" type="primary" class='ivu-btn-cancel' @click="handleCancel">取消</Button>
				<Button v-if="mode === 'view'" class='ivu-btn-save' @click="dialogShow=false">关闭</Button>
			</div>
		</Modal>

    <Modal :transfer=false title="批量导入" v-model="modal9" width="800">
        <Form ref="uploadItemData">
            <Row>
                <i-col span="12">
                    <FormItem label='单位名称：' prop='companyId'>
                        <cascader-dom v-if="modal9" class='query-form-el' ref='orgCascader2' @setOrgInfo='setCompanyId2' @setOrgname="setCompanyName2" :orgTree="true"
                                       :currentOrgId="uploadMap.companyId"
                                       :setCurrentName="{label:uploadMap.companyName,value:uploadMap.companyId}" ></cascader-dom>
                    </FormItem>
                </i-col>
				<i-col span="12">
                    <FormItem label='地理位置：' prop='address'>
                        <Input class='query-form-el' placeholder="A省B市C县D街道1号" type='text'
							 v-model='uploadMap.address'></Input>
                    </FormItem>
                </i-col>
            </Row>
            <Row>
                <i-col span="24">
                    <Upload
                            name="file"
                            type="drag"
                            :format="['xlsx', 'xls']"
                            accept=".xlsx, .xls"
                            :before-upload="handleUpload "
                            action="//jsonplaceholder.typicode.com/posts/">
                        <div style="padding: 20px 0">
                            <Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon>
                            <p>请上传xls、xlsx格式的文件</p>
                        </div>
                    </Upload>
                </i-col>
            </Row>
            <div v-if="fileTrue">
                <a>{{ uploadMap.file.name }}</a>
                <Button type="text" icon="md-trash" @click="uploadMap.file = {},fileTrue = false" style="margin-left: 5px;margin-bottom: 3px"/>
            </div>
        </Form>
        <div slot="footer">
            <Button class='ivu-btn-save' @click="submitFile()">上传</Button>
            <Button @click="modal9 = false" class="ivu-btn-cancel" >取消</Button>
        </div>
    </Modal>
    <Modal :transfer=false title="异常数据，请检查模板" v-model="modal10" width="800">
        <!-- <div :style="{height: '200px', overflowY: 'auto', overflowX: 'auto'}"> -->
            <Table ref='table3' border :columns="errorColumns" style="margin-top: 0px"
                   :data="errorInfos" width="100%" :height="500" highlight-row stripe size="small"></Table>
        <!-- </div> -->
        <div slot="footer">
            <Button class='ivu-btn-cancel' @click="modal10=false;errorInfos=[]">取消</Button>
        </div>
    </Modal>

	<Modal :transfer=false title="地理位置修改" v-model="model11" width="700">
        <Form ref="addressEdit" :model="editMap" label-position="right" :label-width="100" >
            <Row>
                <i-col span="24">
                    <FormItem label='单位名称：'>
						<Input class='query-form-el' readonly type='text' v-model='editMap.companyName'></Input>
                    </FormItem>
                </i-col>
				<i-col span="24">
                    <FormItem label='地理位置：' prop='address'>
                        <Input class='query-form-el' placeholder="A省B市C县D街道1号" type='text' v-model='editMap.address'></Input>
                    </FormItem>
                </i-col>
            </Row>
        </Form>
        <div slot="footer">
            <Button class='ivu-btn-save' @click="submitAddress('addressEdit')">确定</Button>
            <Button @click="model11 = false,editMap={}" class="ivu-btn-cancel" >取消</Button>
        </div>
    </Modal>
	</Layout>
</template>

<script>
import {Api} from '@/api/index.js'
import pageCommonFunction from '@/components/pageCommonFunction.js'
import {sessionStorage} from '@/common/cacheUtils.js';

var cascaderDom = () => import('@/components/cascader-dom.vue');
export default {
  components: {
    cascaderDom
  },
  data() {
    return {
      ...this.createCommonDataField(),
      statisticPage: true,
      imgUrl: "",
      columns1: [
        {title: '序号', width: 70, fixed: 'left', align: 'center', render: this.indexColumnsRender},
					{
						key: 'companyName',
						title: '单位名称',
						align: 'center',
						minWidth: 120,
					},
					{
						key: 'address',
						title: '地理位置',
						align: 'center',
						minWidth: 120,
					},
					{
						key: 'typeName',
						title: '类型/代码',
						align: 'center',
						minWidth: 120,
					},
					// {
					// 	key: 'equipmentName',
					// 	title: '装备名称',
					// 	align: 'center',
					// 	minWidth: 120,
					// },
					{
						key: 'specification',
						title: '规格型号',
						align: 'center',
						minWidth: 120,
					},
					{
						key: 'number',
						title: '数量',
						align: 'center',
						minWidth: 120,
					},
					{
						key: 'source',
						title: '来源',
						align: 'center',
						minWidth: 120,
					},
					{
						key: 'completionDesc',
						title: '完好情况或有效期',
						align: 'center',
						minWidth: 120,
					},
					{
						key: 'mainFunction',
						title: '主要功能',
						align: 'center',
						minWidth: 120,
					},
					{
						key: 'storageLocation',
						title: '存放场所',
						align: 'center',
						minWidth: 120,
					},
					{
						key: 'chargeUserId',
						title: '负责人',
						align: 'center',
						minWidth: 120,
					},
					{
						key: 'chargeUserPhone',
						title: '负责人电话',
						align: 'center',
						minWidth: 120,
					},
					this.getActionColumns(),
				],
				ruleCustom: {
					companyId: [{
						required: true,
						message: '请填写单位名称',
						trigger: 'change',
					}],
					type: [{
						required: true,
						message: '请填写类型',
						trigger: 'change',
					}],
					address: [{
						required: true,
						message: '请填写地理位置：',
						trigger: 'change',
					}],
					// equipmentName: [{
					// 	required: true,
					// 	message: '请填写装备名称',
					// 	trigger: 'change',
					// }],
					specification: [{
						required: true,
						message: '请填写规格型号',
						trigger: 'change',
					}],
					number: [{
						required: true,
						message: '请填写数量',
						trigger: 'change',
						type: 'number'
					}],
					source: [{
						required: true,
						message: '请填写来源',
						trigger: 'change',
					}],
					completionDesc: [{
						required: true,
						message: '请填写完好情况或有效期',
						trigger: 'change',
					}],
					mainFunction: [{
						required: true,
						message: '请填写主要功能',
						trigger: 'change',
					}],
					storageLocation: [{
						required: true,
						message: '请填写存放场所',
						trigger: 'change',
					}],
					chargeUserId: [{
						required: true,
						message: '请填写负责人',
						trigger: 'change',
					}],
					chargeUserPhone: [{
						validator: (rule, value, callback) => {
							if (!(/^1[3456789]\d{9}$/.test(this.dataToView.chargeUserPhone))) {
								callback(' ');
								// this.$Message.error("请填写有效的的手机号")
							} else {
								callback()
							}
						},
						required: true,
						trigger: 'blur'
					}],
				},

				columns2: [
                    {title: '序号', width: 65, fixed: 'left', align: 'center', render: this.indexColumnsRender},
                    {key: 'companyName', title: '单位名称', align: 'center', minWidth: 200},
					{key: 'address',title: '地理位置',align: 'center',minWidth: 120,},
                    {key: 'str', title: '类型信息', align: 'center', minWidth: 160,tooltip:true},
										{key: 'createDate', title: '最新上传时间', align: 'center',width:140, render: this.renderCellDate, sortable: 'custom' },
                    // {key: 'belongOrgName', title: '二级集团', align: 'center', minWidth: 150},
                    {
                        title: '操作',
                        key: 'action',
                        fixed: 'right',
                        width: 120,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('A', {
                                    props: {type: 'primary', size: 'small'},
                                    style: {
                                        fontSize: '14px',
                                    },
                                    on: {
                                        click: () => {
                                            this.statisticPage = false
                                            this.dataToQuery.companyName = params.row.orgName
                                            this.dataToQuery.companyId = params.row.companyId
                                            this.query()
                                        }
                                    }
                                }, '详情'),
								h('Divider', {props: {type: 'vertical'}}, ''),
								h('A', {
                                    props: {type: 'primary', size: 'small'},
                                    style: {
                                        fontSize: '14px',
                                    },
                                    on: {
                                        click: () => {
											let row = {...params.row}
                                            this.editMap.companyName = row.orgName
                                            this.editMap.companyId = row.companyId
											this.editMap.address = row.address
											this.model11 = true
                                        }
                                    }
                                }, '修改'),
                            ])
                        }
                    }
                ],
				// ruleCustom1: {
				// 	companyId: [{
				// 		required: true,
				// 		message: '请填写单位名称',
				// 		trigger: 'change',
				// 	}],
				// 	address: [{
				// 		required: true,
				// 		message: '请填写地理位置：',
				// 		trigger: 'change',
				// 	}]
				// },
				editMap:{},
				model11: false,

				tableHeight: 10,
				dictMap: {},
				punishment: false,
				penaltyAmount: true,
				// api
				queryUrl: Api.queryEmergencyResources,
				exportUrl: Api.exportEmergencyResources,
				deleteUrl: Api.deleteEmergencyResources,
				getUrl: Api.getEmergencyResources,
				updateUrl: Api.updateEmergencyResources,
				saveUrl: Api.saveEmergencyResources,

				currentUser: JSON.parse(sessionStorage('userId').get('userId')),
				// options: {
				//     disabledDate (date) {
				//         return date && date.valueOf() >= new Date();
				//     }
				// },

				uploadMap:{},
				modal9: false,
				modal10: false,
				fileTrue: false,
				errorInfos: [],
				errorColumns: [
				    { key:'index',title: '序号', width: 70, align: 'center'},
					{
						key: 'typeName',
						title: '类型/代码',
						align: 'center',
						minWidth: 120,
					},
					{
						key: 'typeName1',
						title: '子类型',
						align: 'center',
						minWidth: 120,
					},
				    // {
				    // 	key: 'equipmentName',
				    // 	title: '装备名称',
				    // 	align: 'center',
				    // 	minWidth: 120,
				    // },
				    {
				    	key: 'specification',
				    	title: '规格型号',
				    	align: 'center',
				    	minWidth: 120,
				    },
				    {
				    	key: 'number',
				    	title: '数量',
				    	align: 'center',
				    	minWidth: 120,
				    },
				    {
				    	key: 'source',
				    	title: '来源',
				    	align: 'center',
				    	minWidth: 120,
				    },
				    {
				    	key: 'completionDesc',
				    	title: '完好情况或有效期',
				    	align: 'center',
				    	minWidth: 120,
				    },
				    {
				    	key: 'mainFunction',
				    	title: '主要功能',
				    	align: 'center',
				    	minWidth: 120,
				    },
				    {
				    	key: 'storageLocation',
				    	title: '存放场所',
				    	align: 'center',
				    	minWidth: 120,
				    },
				    {
				    	key: 'chargeUserId',
				    	title: '负责人',
				    	align: 'center',
				    	minWidth: 120,
				    },
				    {
				    	key: 'chargeUserPhone',
				    	title: '负责人电话',
				    	align: 'center',
				    	minWidth: 120,
				    },
				],
			}
		},
		async mounted() {
			this.setTableHeight();
			this.$http.get(Api.queryDictBycode+"PL-000011",{}).then((res)=>{
                this.dictMap = {
                    'typeArr': getTreeDate(res.data.data['PL-000011'],[],"0")
                }
				function getTreeDate(data,treeData,parentCoding){
					let dataBack = [...data]
					data.forEach(item => {
						if((item.parentCoding?item.parentCoding:"0") === parentCoding){
							dataBack.splice(item,1)
							let m = {
								value: item.codingCodeId,
								label: item.codingName,
								children: getTreeDate(dataBack,[],item.codingCodeId)
							}
							treeData.push(m)
						}
					})
					return treeData;
				}
            })
			this.query();
		},
		methods: {
			...pageCommonFunction,
			submitAddress(){
				if (!this.editMap.address) {
          this.$Message.error("地理位置不能是空");
          return
        }
				this.$Modal.confirm({
					title: '提示',
					content: '<p>是否要提交？</p>',
					onOk: () => {
						this.$http.post(Api.queryEmergencyResources+'/page/update', this.editMap).then(res => {
							if (res.data.status === 200) {
								this.$Message.success('修改成功');
								this.model11 = false;
								this.editMap={}
								this.query()
							} else if (res.data.status === 201) {
								this.$Message.error(res.data.msg);
							}
						}).catch(res=>{
							this.$Message.error('修改失败')
						})
					},
					onCancel: () => {
					}
				});
			},
			setCompanyId2(data) {
			    if (data && data instanceof Array && data.length > 0) {
			        this.$set(this.uploadMap, 'companyId', data[data.length - 1])
			    }
			},
			setCompanyName2(data) {
			    if (data) {
			        this.uploadMap.companyName = data;
			    }
			},
			openUpload(){
			    this.fileTrue = false
			    this.uploadMap = {
			        companyId:this.currentUser.companyId,
			        companyName:this.currentUser.companyName,
			    }
			    this.modal9 = true;
			},
			handleUpload (file) {
			    this.uploadMap.file = file;
			    this.fileTrue = true;
			    return false;
			},
			submitFile(){
				if (!this.uploadMap.address) {
          this.$Message.error("地理位置不能是空");
          return
        }
			    let formData = new FormData();
			    formData.append("file", this.uploadMap.file);
			    formData.append("companyId", this.uploadMap.companyId);
				formData.append("address", this.uploadMap.address);
			    formData.append("createUserId", this.currentUser.userId);
			    formData.append("createOrgId", this.currentUser.orgInfo.orgId);
			    this.$http.post(Api.queryEmergencyResources + '/upload', formData).then((res) => {
			        if(res.data.status == 201){
			            this.$Message.error(res.data.msg);
			            this.modal10 = true;
			            let title = ['typeName','typeName1','equipmentName','specification','number','source','completionDesc','mainFunction','storageLocation','chargeUserId','chargeUserPhone']
			            res.data.data.map((i=>{
			                let cellClassName = {}
			                for (let k in title) {
			                    if (i[title[k]] == null){
			                        cellClassName[title[k]] = "table-info-cell-red";
			                    }
			                }
			                i.cellClassName = cellClassName;
			            }));
			            this.errorInfos = res.data.data;
			        }else if(res.data.status == 200){
			            this.$Message.success("批量导入成功");
			           /* let dataItems = res.data.data
			            dataItems.forEach(item =>{
			                this.dataToView.items.push(item);
			            })*/
			            this.modal9 = false;
			            this.fileTrue = false
			            this.query()
			        }
			    }).catch(e => {
			        console.log(e)
			        this.$Message.error("导入失败！请检查导入文档的格式是否正确");
			    })
			},
			downloadModel(){
			    this.$http.get(Api.queryEmergencyResources + '/upload/model',{
			        params: {},
			        responseType: 'arraybuffer'
			    }).then((res) => {
			        const aLink = document.createElement("a");
			        let blob = new Blob([res.data], {
			            type: "application/vnd.ms-excel"
			        })
			        aLink.href = URL.createObjectURL(blob);
			        aLink.download = "应急资源导入模板.xlsx" //标题
			        aLink.click();
			        document.body.appendChild(aLink);

					// const link = document.createElement('a')
					// const blob = new Blob([res.data])
					// link.style.display = 'none'
					// link.href = URL.createObjectURL(blob)
					// link.setAttribute('download', "应急资源导入模板.xlsx")
					// document.body.appendChild(link)
					// link.click()
					// document.body.removeChild(link)
			    })
			},


      deleteData(params) {
				this.deleteDateAjax(params);
			},

			goback(){
                if (this.switchFlag) {
                    this.switchQuery(false)
                }
				this.pagedata.currentPage=1
                this.statisticPage = true
                this.dataToQuery = {}
                this.query()
            },

			query() {
				if (this.dataToQuery.typeArr) {
					this.dataToQuery.type = this.dataToQuery.typeArr[this.dataToQuery.typeArr.length-1]
				} else{
					delete this.dataToQuery['type']
				}

        this.queryUrl =this.statisticPage ? Api.queryEmergencyResources+'/page':Api.queryEmergencyResources
				this.queryAjax();
				// this.pageStatus.loading = true
				// let data = {
				// 	startPage: this.pagedata.currentPage,
				// 	size: this.pagedata.pageSize,
				// 	conditions: this.dataToQuery
				// };

				// this.$http.post(url, data).then((res) => {
				// 	if (res.data.status === 201) {
				// 		this.$Message.error(res.data.msg);
				// 	}
				// 	this.dataTable = res.data.data.data;
				// 	this.pagedata.total = res.data.data.totalSize;
				// 	this.pageStatus.loading = false
				// }).catch(e => {
				// 	this.$Message.error("数据获取失败")
				// 	this.pageStatus.loading = false
				// })
			},

			async beforeEditDialogOpen(data) {
			    data.row.type = data.row.type.split(',')
			},
			submit(name) {
				if (this.dataToView.type) {
					this.dataToView.type = this.dataToView.type.join(',')
				}
				this.submitAjax(name);
			},
			createEmptyDataToAdd() {
				return {
					createDate: new Date(),
					createUserId: this.currentUser.userId,
					createUserName: this.currentUser.userName,
					id: this.get_uuid(),
					number: 0,
					idFiles: [],
				}
			},
      querySort({column, key, order}){
        this.dataToQuery.key = key;
        this.dataToQuery.order = order;
        this.query();
      }
			// async afterDataToViewInit() {
			//     await this.getFiles('id');
			// },
		},
		watch: {},
	}
</script>

<style lang='css' scoped>
	.ivu-form-item {
		padding-right: 20px;
	}

	.query-form-el,
	.ivu-date-picker,
	.ivu-input-wrapper {
		width: 100%;
	}
</style>
